package com.mercury.ec.framework.air.core.client.impl.skyecho.util;


import org.apache.commons.lang3.ArrayUtils;

import javax.crypto.Cipher;
import java.io.UnsupportedEncodingException;
import java.math.BigInteger;
import java.security.Key;
import java.security.KeyFactory;
import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.interfaces.RSAPrivateKey;
import java.security.interfaces.RSAPublicKey;
import java.security.spec.PKCS8EncodedKeySpec;
import java.security.spec.X509EncodedKeySpec;
import java.util.HashMap;
import java.util.Map;

/**
 * RSA加密与解密,采用Base64编码
 * @author yangql
 * @date Jan 18, 2021
 */
public class RSAProvider {

	/**
     * KEY_ALGORITHM
     */
    public static final String KEY_ALGORITHM = "RSA";
    /**
     * 加密Key的长度等于1024或者2048
     */
    public static int KEYSIZE = 2048;
    /**
     * 解密时必须按照此分组解密
     */
    public static int decodeLen = KEYSIZE / 8;
    /**
     * 加密时小于117即可
     */
    public static int encodeLen = 100;
    /**
     * 公钥
     */
    private static final String PUBLIC_KEY = "publicKey";
    /**
     * 私钥
     */
    private static final String PRIVATE_KEY = "privateKey";
    /**
     * MODULES
     */
    private static final String MODULES = "RSAModules";

    /**
     *
     * 生成KeyPair
     * @return
     * @throws Exception
     * @author East271536394
     */
    public static Map<String, Object> generateKeyPair() throws Exception {
        KeyPairGenerator keyPairGen = KeyPairGenerator.getInstance(KEY_ALGORITHM);
        keyPairGen.initialize(KEYSIZE);
        KeyPair keyPair = keyPairGen.generateKeyPair();

        // 公钥
        RSAPublicKey publicKey = (RSAPublicKey) keyPair.getPublic();

        // 私钥
        RSAPrivateKey privateKey = (RSAPrivateKey) keyPair.getPrivate();
        BigInteger modules = privateKey.getModulus();

        Map<String, Object> keys = new HashMap<String, Object>(3);
        keys.put(PUBLIC_KEY, publicKey);
        keys.put(PRIVATE_KEY, privateKey);
        keys.put(MODULES, modules);
        return keys;
    }

    /**
     *
     * 加密private key
     * @param data
     * @param key
     * @return
     * @throws Exception
     * @author East271536394
     */
    public static byte[] encryptPrivateKey(String data, String key) throws Exception {
        byte[] bytes = data.getBytes("UTF-8");
        byte[] encode = new byte[] {};
        for (int i = 0; i < bytes.length; i += encodeLen) {
            byte[] subarray = ArrayUtils.subarray(bytes, i, i + encodeLen);
            byte[] doFinal = encryptByPrivateKey(subarray, key);
            encode = ArrayUtils.addAll(encode, doFinal);
        }
        return encode;
    }

    /**
     * 解密 public key
     * 方法说明。
     * @param encode
     * @param key
     * @return
     * @throws Exception
     * @author East271536394
     */
    public static String decryptPublicKey(byte[] encode, String key) throws Exception {
        byte [] buffers = new byte[]{};
        for (int i = 0; i < encode.length; i += decodeLen) {
            byte[] subarray = ArrayUtils.subarray(encode, i, i + decodeLen);
            byte[] doFinal = decryptByPublicKey(subarray, key);
            buffers = ArrayUtils.addAll(buffers, doFinal);
        }
        return new String(buffers, "UTF-8");
    }

    /**
     *
     * 加密public key
     * @param data
     * @param key
     * @return
     * @throws Exception
     * @author East271536394
     */
    public static byte[] encryptPublicKey(String data, String key) throws Exception {
        byte[] bytes = data.getBytes("UTF-8");
        byte[] encode = new byte[] {};
        for (int i = 0; i < bytes.length; i += encodeLen) {
            byte[] subarray = ArrayUtils.subarray(bytes, i, i + encodeLen);
            byte[] doFinal = encryptByPublicKey(subarray, key);
            encode = ArrayUtils.addAll(encode, doFinal);
        }
        return encode;
    }

    /**
     * 解密 private key
     * 方法说明。
     * @param encode
     * @param key
     * @return
     * @throws Exception
     * @author East271536394
     */
    public static String decryptPrivateKey(byte[] encode, String key) throws Exception {
        byte [] buffers = new byte[]{};
        for (int i = 0; i < encode.length; i += decodeLen) {
            byte[] subarray = ArrayUtils.subarray(encode, i, i + decodeLen);
            byte[] doFinal = decryptByPrivateKey(subarray, key);
            buffers = ArrayUtils.addAll(buffers, doFinal);
        }
        return new String(buffers, "UTF-8");
    }

    /**
     * 用私钥解密
     * @param data
     * @param keyBytes
     * @return
     * @throws Exception
     * @author East271536394
     */
    private static byte[] decryptByPrivateKey(byte[] data, String key) throws Exception {
        // 对密钥解密  取得私钥
        byte[] keyBytes = b64decode(key);
        PKCS8EncodedKeySpec pkcs8KeySpec = new PKCS8EncodedKeySpec(keyBytes);
        KeyFactory keyFactory = KeyFactory.getInstance(KEY_ALGORITHM);
        Key privateKey = keyFactory.generatePrivate(pkcs8KeySpec);

        // 对数据解密
        Cipher cipher = Cipher.getInstance(keyFactory.getAlgorithm());
        cipher.init(Cipher.DECRYPT_MODE, privateKey);

        return cipher.doFinal(data);
    }

    /**
     *
     * 用公钥解密
     * @param data
     * @param keyBytes
     * @return
     * @throws Exception
     * @author East271536394
     */
    private static byte[] decryptByPublicKey(byte[] data, String key) throws Exception {
        // 对密钥解密   取得公钥
        byte[] keyBytes = b64decode(key);
        X509EncodedKeySpec x509KeySpec = new X509EncodedKeySpec(keyBytes);
        KeyFactory keyFactory = KeyFactory.getInstance(KEY_ALGORITHM);
        Key publicKey = keyFactory.generatePublic(x509KeySpec);

        // 对数据解密
        Cipher cipher = Cipher.getInstance(keyFactory.getAlgorithm());
        cipher.init(Cipher.DECRYPT_MODE, publicKey);

        return cipher.doFinal(data);
    }

    /**
     *
     * 用公钥加密
     * @param data
     * @param keyBytes
     * @return
     * @throws Exception
     * @author East271536394
     */
    private static byte[] encryptByPublicKey(byte[] data, String key) throws Exception {
        // 对公钥解密
        // 取得公钥
        byte[] keyBytes = b64decode(key);
        X509EncodedKeySpec x509KeySpec = new X509EncodedKeySpec(keyBytes);
        KeyFactory keyFactory = KeyFactory.getInstance(KEY_ALGORITHM);
        Key publicKey = keyFactory.generatePublic(x509KeySpec);

        // 对数据加密
        Cipher cipher = Cipher.getInstance(keyFactory.getAlgorithm());
        cipher.init(Cipher.ENCRYPT_MODE, publicKey);

        return cipher.doFinal(data);
    }

    /**
     * 用私钥加密
     *
     * @param data
     * @param keyBytes
     * @return
     * @throws Exception
     * @author East271536394
     */
    private static byte[] encryptByPrivateKey(byte[] data, String key) throws Exception {
        // 对密钥解密
        // 取得私钥
        byte[] keyBytes = b64decode(key);
        PKCS8EncodedKeySpec pkcs8KeySpec = new PKCS8EncodedKeySpec(keyBytes);
        KeyFactory keyFactory = KeyFactory.getInstance(KEY_ALGORITHM);
        Key privateKey = keyFactory.generatePrivate(pkcs8KeySpec);

        // 对数据加密
        Cipher cipher = Cipher.getInstance(keyFactory.getAlgorithm());
        cipher.init(Cipher.ENCRYPT_MODE, privateKey);

        return cipher.doFinal(data);
    }

    /**
     *
     *
     * @return
     * @author East271536394
     */
    public static byte[] getModulesBytes(Map<String, Object> keys) {
        BigInteger big = (BigInteger) keys.get(MODULES);
        return big.toByteArray();

    }

    /**
     *
     * 取得私钥
     * @return
     * @throws Exception
     * @author East271536394
     */
    public static String getPrivateKeyBytes(Map<String, Object> keys) throws Exception {
        Key key = (Key) keys.get(PRIVATE_KEY);
        return b64encode(key.getEncoded());
    }
    /**
     * 解密验证签名
     */
    public static Map<Object, Object> decryptSignData(String data, String sign,
			String privateKey, String publicKey) {
		HashMap<Object, Object> map = new HashMap<Object, Object>();
		try {
			String decryptPrivateKey = RSAProvider.decryptPrivateKey(
					b64decode(data), privateKey);
			// 公钥验证签名
			Boolean isAccess = RSASignature.doCheck(decryptPrivateKey, sign,
					publicKey);
			byte[] decryptPrivate = b64decode(decryptPrivateKey);
			decryptPrivateKey = new String(decryptPrivate,"utf-8");
			map.put("decryptData", decryptPrivateKey);
			map.put("isAccess", isAccess);
		} catch (Exception e) {
			e.printStackTrace();

		}
		return map;
	}

	/**
	 * 加密签名
	 *
	 */
	public static Map<String, String> encryptSignData(String data,
			String privateKey, String publicKey) {
		try {
			data = b64encode(data.getBytes("utf-8"));
		} catch (UnsupportedEncodingException e1) {
			e1.printStackTrace();
		}
		HashMap<String, String> map = new HashMap<String, String>();
		try {
			byte[] encryptPublicKey = RSAProvider.encryptPublicKey(data,
					publicKey);
			String byteToBase64 = b64encode(encryptPublicKey);
			String returnSign = RSASignature.sign(data, privateKey);
			map.put("encryptData", byteToBase64);
			map.put("encrytSign", returnSign);
		} catch (Exception e) {
			e.printStackTrace();

		}
		return map;
	}

    /**
     * 取得公钥
     *
     * @return
     * @throws Exception
     * @author East271536394
     */
    public static String getPublicKeyBytes(Map<String, Object> keys) throws Exception {
        Key key = (Key) keys.get(PUBLIC_KEY);
        return b64encode(key.getEncoded());
    }

    public static void main(String[] args) {
		String privateKey = "MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAOS18KW+D/riRe/97HhBHPeWVE86AXr+0FiyP2dnYC4zi4hvV/zJhKRjhLeDhsHIZK93IwxyMr3/6PJQF8sl4Ne6E65JtqPh4scG1rY7i1KofDJtHqfURDjOTLdOiDkdAOJontAWkhOJSsrWk1gQOigBBNsVb+DPc0O2R9F871uTAgMBAAECgYAf7ZpLuQ3IC2CSEVO6sfRWSAE7EjD0t6/kQfYB/Hd726xF/q081/ERdecoK09brBsKN8qHyUV2KsydTzsTHBWYJHXJ8ykgZktZoj2H4khmhkomlDtEsRD30qD7XqAABIgCLqweREMEXhHgoYMTHlo2y8e94r98bPzNewBT84nHgQJBAP8GuMQQEkZ11i/zwzaD/aq2hjCZ01VaRu0rspjI8cM9Ttlp3ehL9unS+r0Z/PcCzEp68QIISVN2Lnt84oCp0MECQQDllX7wbL5y/+2Tuh8KDqsgSDVyDRnEkY4qas4LsfER2f9S7UmyAF1z801jb8TFg+H3jU820YYRGBJaY4tZHu1TAkEApf0aBYLwYiwQXOWsCa+fS53BeaCljMhVocjvVcJ0mT8uMxRU+v12mHpZ+PsRSzTnAxNCCrCaCVjCqF2Aj334AQJAJFLn16BM7aMCcsoS2SOC/cOO+TGLbydcZ+eoG/+WVa25EOTMMSaPoqXPC7mGV33LRcCM1O6HmLLHTJfNV1dmUwJAVbb9LBEs9BpBQyFw1DxV6qmqP2MqsrFZ4LeyFlRuG4Jl1JvQr5E4T3nUg2Tu86fn2s4KK+OMVM2IxyVYXQeK6w==";
		String publicKey = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDktfClvg/64kXv/ex4QRz3llRPOgF6/tBYsj9nZ2AuM4uIb1f8yYSkY4S3g4bByGSvdyMMcjK9/+jyUBfLJeDXuhOuSbaj4eLHBta2O4tSqHwybR6n1EQ4zky3Tog5HQDiaJ7QFpITiUrK1pNYEDooAQTbFW/gz3NDtkfRfO9bkwIDAQAB";
		String pri = "MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAKM2+gw0WIgoT4gDYn2OelNwJWv8KHX9TD6M2qBzJFUJ21cUeu6pUkyrLjPVa+NEqJcls+RpzPK18QUUtuX/Jx+o6TQNfLF5/BE+nFUedQ0U+nSIt5Zb/zAQQERexf2JBiPx2nggm5BwjJDobbVKftIkwQL1G8dN5DsSrtVN8fhXAgMBAAECgYAte4mM0x2Eu+8F0SOmJ4kxLURQZlGEJ9USbUATjGKoi/mit6NWVLsJgH58lVHeYGi2zhvmYBFr5YXHy7D4QPVOrBq0Q68HJJkJZYyZ7Zi2nKkqiH5WoGaiuziRHQoalsreYbm4TmUIi0CaodC+Z4HcuxalZuENCATd0PNoBbMokQJBANruJn2ZgrZF7/476VUGL8VjSuO1hcld6YM2QSXhKXL2kfGAeR6xDojUbDvpU/YR8zTCbcpkv26/ofCzSyOELokCQQC+2cGm/4ASG7ppWX1gPMcBAxDlA2w45p4tAGuEbj8RinHLiFK+8zolYTym3OIP6x9R9PW5ttmLCjg/OEN13jffAkEAsDihote97xm8Y9e1qUqhiTCzRzcFyWBeZc92AReMVY1DTDEtTRcXq+vQcykM/DTWntEhrpgJvwthPm4TPTNYgQJAYUXlsPNK2G/vjCCDiZiQqZBhfQhIkZvhhPhQ1JfIZ21T4LQj0JVxznmIC1hLlGd3eDNNRxHOQVK9JmPL5niTqwJAaHz3B5LJIZWZS3RP7yCdKtEXmVzX6i/MrueAc3tjqXtBB826CvjoCGjxa6nSsS99mJPqdZ/sjAri3oc5q5W2Sg==";
		String pub = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCjNvoMNFiIKE+IA2J9jnpTcCVr/Ch1/Uw+jNqgcyRVCdtXFHruqVJMqy4z1WvjRKiXJbPkaczytfEFFLbl/ycfqOk0DXyxefwRPpxVHnUNFPp0iLeWW/8wEEBEXsX9iQYj8dp4IJuQcIyQ6G21Sn7SJMEC9RvHTeQ7Eq7VTfH4VwIDAQAB";
		String data = "{\"accountName\":\"TAO182\",\"bcTktChangeSynVO\":null,\"bcTktRefundSynVO\":null,\"journeySynVO\":{\"agentId\":171,\"airItemPayStatus\":\"n\",\"airItemSynVOList\":[{\"agentId\":171,\"airItemInsureSynVOList\":null,\"airItemNo\":4297668,\"airItemState\":\"1\",\"airportTax\":50.0,\"airportTaxForLowest\":50.0,\"autoCancelFlag\":null,\"bookedLowestType\":\"2\",\"bpnr\":\"MEWPD2\",\"cancelFlag\":\"0\",\"contrContent\":null,\"contrContentEn\":null,\"contrPolicy\":\"2\",\"contrReason\":null,\"contrReasonEn\":null,\"createtime\":1524015782000,\"ei\":null,\"eiEn\":null,\"fuelTax\":0.0,\"fuelTaxForLowest\":0.0,\"gpOrderNo\":null,\"gpPayType\":null,\"gpPurchaseCardNo\":null,\"hasServiceFee\":\"0\",\"ifSupplement\":\"0\",\"isAutoTkt\":null,\"isHandle\":null,\"isTcBooked\":null,\"issueBy\":\"1\",\"issueMachineNo\":\"1\",\"jourType\":\"OW\",\"journeyCreatetime\":1524015782000,\"journeyNo\":102354748,\"lostVolume\":null,\"lowestType\":null,\"masterTktMachineNo\":\"1\",\"officeNo\":\"TAO182\",\"oi\":null,\"otherPrice\":null,\"parGuestname\":\"周廷清\",\"passengerSynVOList\":[{\"agentId\":171,\"airItemNo\":4297668,\"birthday\":549298800000,\"certNo\":\"511602198705300517\",\"certType\":\"1\",\"corpCode\":\"ecidi\",\"corpId\":75403,\"costCenterDepartMentId\":70195,\"costCenterInfo\":\"华东勘测设计研究院/水工工程院/水工一室\",\"departMentId\":70195,\"departmentName\":\"水工工程院/水工一室\",\"email\":\"skt@chinahtg.com\",\"employeeNo\":\"2010473\",\"expireDate\":null,\"gender\":\"M\",\"gpCheckNum\":null,\"holderNationality\":null,\"hostName\":\"周廷清\",\"hotelItemId\":null,\"insureNumber\":null,\"isCheckInPerson\":null,\"isTempPsg\":\"0\",\"issueChannel\":\"1\",\"issueCountry\":null,\"issueExPlatform\":\"0\",\"issueRemark\":\"自有BSP出票\",\"journeyCreatetime\":1524015782000,\"mailAddr\":null,\"memCard\":null,\"mobile\":\"18758018960\",\"parSynVOList\":null,\"passengerId\":4896402,\"passengerType\":null,\"psgName\":\"周廷清\",\"psgNameEn\":\"周廷清\",\"psgParCode\":null,\"psgParId\":2117938,\"seatPrice\":null,\"seatType\":null,\"sequenceNo\":\"1\",\"showInSchedule\":\"1\",\"ticketNumber\":\"999-5389722937\",\"ticketState\":\"1\",\"ticketType\":\"1\",\"trainBCStatus\":null,\"trainBox\":null,\"trainInsureNo\":null,\"trainInsureNum\":null,\"trainInsurePrice\":null,\"trainInsureType\":null,\"trainItemID\":null,\"trainPrice\":null,\"trainRefundAmount\":null,\"trainRefundFailReason\":null,\"trainRefundID\":null,\"trainRefundStatus\":null,\"trainSeatNo\":null,\"trainSeatType\":null}],\"pnrCreatetime\":1524015720000,\"pnrNo\":\"KPS9B0\",\"priceType\":\"PRO\",\"priceTypeDesc\":\"协议价\",\"referenceId\":\"381cff63f62240cbb2528f03a8b27947\",\"rmkCms\":10.0,\"segmentSynVOList\":[{\"accountCode\":\"9CN10G9P\",\"actionCode\":\"HK\",\"agentId\":171,\"airItemNo\":4297668,\"airlineShortName\":\"国航\",\"airportTax\":50.0,\"arriveAirportName\":\"昆明机场\",\"arriveCity\":\"KMG\",\"arriveCityName\":\"昆明\",\"arriveStn\":\"KMG\",\"arriveTerminal\":null,\"arriveTime\":1524105300000,\"bankCharges\":null,\"bankChargesRate\":null,\"baseCabin\":\"Y\",\"baseFare\":\"V\",\"cabinCode\":\"V\",\"cabinDiscount\":\"6.3\",\"cabinType\":\"Y\",\"carriageAirline\":null,\"carriageFltNo\":null,\"craftTypeCode\":\"319\",\"ei\":\"余额再收40%退票费 余额再收30%退票费 当客票全部未使用，变更费按订座舱位公布运价30%收取。升舱差额和变更费同时发生时，累加差额和变更费用。 当客票全部未使用，变更费按订座舱位公布运价20%收取。升舱差额和变更费同时发生时，累加差额和变更费用。 \",\"eiEn\":\"余额再收40%退票费 余额再收30%退票费 当客票全部未使用，变更费按订座舱位公布运价30%收取。升舱差额和变更费同时发生时，累加差额和变更费用。 当客票全部未使用，变更费按订座舱位公布运价20%收取。升舱差额和变更费同时发生时，累加差额和变更费用。 \",\"externalPriceFormula\":null,\"flytime\":\"03:05\",\"formulaName\":null,\"fuelTax\":0.0,\"fullPrice\":null,\"inPrice\":null,\"journeyCreatetime\":1524015782000,\"marketAirline\":\"CA\",\"marketFltNo\":\"1751\",\"mealcode\":\"B\",\"oi\":\"O\",\"outDiscount\":null,\"price\":1510.0,\"pubPrice\":1510.0,\"salePrice\":null,\"salePriceFormula\":null,\"saleStrategyId\":null,\"seat\":null,\"segmentId\":4330639,\"segmentInsureSynVO\":null,\"sequenceNo\":\"1\",\"standardPrice\":2390.0,\"stopTime\":null,\"stopover\":\"0\",\"stoppingPlaces\":null,\"takeoffAirprotName\":\"杭州机场\",\"takeoffCity\":\"HGH\",\"takeoffCityName\":\"杭州\",\"takeoffStn\":\"HGH\",\"takeoffTerminal\":null,\"takeoffTime\":1524094200000,\"totalPrice\":null,\"tpm\":2089,\"transFee\":null,\"transFeeFormula\":null}],\"serviceFee\":null,\"tktResult\":\"1\",\"tktl\":1524019320000,\"totalPrice\":1510.0,\"totalPriceForLowest\":1510.0,\"totalTax\":50.0,\"totalTaxForLowest\":50.0,\"typeForLowest\":null,\"yFareAmount\":2390.0}],\"alipayNo\":null,\"alterTicketReason\":null,\"alterTicketRemark\":null,\"appJourneyDesc\":null,\"approvalUrgency\":null,\"apvHistorySynVOList\":null,\"apvLevel\":null,\"apvType\":null,\"apvruleId\":94791,\"bcTktSynVOList\":null,\"bookUserType\":\"2\",\"bookerEmail\":\"skt@chinahtg.com\",\"bookerId\":null,\"bookerMobile\":\"15615888860\",\"bookerName\":\"董兰\",\"bookerTel\":\"15615888860\",\"bookerUserName\":\"tao182002\",\"booktime\":1524015819000,\"callBackUrl\":null,\"contactEmail\":\"skt@chinahtg.com\",\"contactName\":\"董兰\",\"contactParId\":null,\"contactTel\":\"15615888860\",\"corpAdmin\":null,\"corpCode\":\"ecidi\",\"corpId\":75403,\"costCenterInfo\":\"华东勘测设计研究院/水工工程院/水工一室(周廷清);\",\"createtime\":1524015782000,\"customFieldSynVals\":null,\"dataFrom\":\"2\",\"description\":null,\"di\":\"d\",\"diffItemSynVO\":null,\"emailType\":null,\"employeeNo\":null,\"externalApprovalNumber\":null,\"hotelItemSynVOList\":null,\"icsAttachment\":null,\"ifSyncOA\":\"0\",\"importTcAccount\":null,\"isApplyEndorseTicket\":null,\"isApplyRefundTicket\":null,\"isEndorseTicket\":null,\"isSendSms4BookedJourney\":null,\"jourPayedRepayedHisSynVoList\":null,\"jourState\":\"6\",\"journeyNo\":102354748,\"journeyPlanOper\":null,\"journeySource\":\"0\",\"manipulate\":null,\"manipulateId\":null,\"needApv\":\"0\",\"needMailPassenger\":\"0\",\"needSendItineraryPdf\":null,\"oaOrderNo\":null,\"orderType\":\"0\",\"parId\":null,\"payCancelReason\":null,\"payFailTimes\":null,\"payconfirm\":null,\"policyUserId\":null,\"privateBookingType\":\"1\",\"psgRemark\":null,\"pushDownState\":null,\"refundTicketReason\":null,\"refundTicketRemarks\":null,\"remark\":null,\"returnReason\":null,\"reversePush\":null,\"selectedApvers\":null,\"sendSmsMobile4BookedJourney\":null,\"serviceCodeId\":587254,\"serviceCodeName\":\"zgdj\",\"stateUpTime\":1524015819000,\"submitDirectly\":null,\"supplierId\":null,\"synOaFlag\":null,\"tcRemark1\":null,\"tcRemark2\":null,\"tcRemark3\":null,\"tcRemark4\":null,\"tcRemark5\":null,\"tcRemark6\":null,\"tcRemark7\":null,\"tcRemark8\":null,\"ticketSyns\":null,\"tktIssueType\":\"2\",\"tktTcAccountName\":null,\"tktTcName\":null,\"trainItemSynVOList\":null,\"travelId\":null,\"travelPolicyId\":81657,\"travelPurpose\":null,\"travelPurposeEn\":null,\"updatePnrRemark\":null,\"workName\":null},\"trainRefundSynVO\":null,\"trainTktChangeSynVOList\":null,\"type\":0}";
		publicKey ="MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEApP/+NsjdlP3vzyqVSBQYaSxIEjUPeIRPgvaI4HuZZkOfwMD1FZ1ziHxMNiNVJpl1Y8bKDJvXwLn5qI2ligwfRTWUzRvCZqpSFjK9qpzH21n+prx8a9en0EjnYqwFtVDfbCIvsksPLmUc18D9VKsbIAtHCskDHxkR7WEP3A8QmWZfxVRTtS4uJWQnhIEEIG+BwTGidTTjRvyXMRo0nphGC3aVafq6oDnJtYnI3sMPZQw0AA8mhG2r7Ohcm9c08EdKxFygAkmMK8dWWyc6zM3KXGUeQPwRaw8SgUd2UDvb8e2JYGcxA325oDINrIJeIebfrpXAOyn7vFIu22o9ag7sZQIDAQAB";
		privateKey="MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCk//42yN2U/e/PKpVIFBhpLEgSNQ94hE+C9ojge5lmQ5/AwPUVnXOIfEw2I1UmmXVjxsoMm9fAufmojaWKDB9FNZTNG8JmqlIWMr2qnMfbWf6mvHxr16fQSOdirAW1UN9sIi+ySw8uZRzXwP1UqxsgC0cKyQMfGRHtYQ/cDxCZZl/FVFO1Li4lZCeEgQQgb4HBMaJ1NONG/JcxGjSemEYLdpVp+rqgOcm1icjeww9lDDQADyaEbavs6Fyb1zTwR0rEXKACSYwrx1ZbJzrMzcpcZR5A/BFrDxKBR3ZQO9vx7YlgZzEDfbmgMg2sgl4h5t+ulcA7Kfu8Ui7baj1qDuxlAgMBAAECggEAF83y8BZ0mV01bs728Iotp2bDExVioQF9syg8QR6z1+QjtRxhf3fSxjsgh6L7UvFK1VVFqyIEs4JhOWcOHed3z3VWfWzm1Ab4hslVQbsSvluyeH2y+aAITu1lrH+i5zC+uwwHk5Juo0PlMF9gbQmuhSX7Xtv3PlJQms2pCxeFTowR1ZkqPlm7qgV1lLZsLRbjI2CYuPQOCym1WuEhPWVI03cjc4YxyvcC39sncJnh+0k9exn2y16cCBEZEXsgC1O5f+oCr3dtONPzz5JtCO5zl6uPkBJJ5A+tNq2KLHPWAnEvbeP5y4+OeOZExgCVCtuuBCvLO2iY9R2eH+Prh/NTYQKBgQDlbzsVoAPCOnC9bneb6hjr2+OWapMWUeZtWN6ayLs/sbgn31qsiIWfc5aZ0EFbZAhsTZczf5N2dAXKjPsk/mfRgAK+WC22boe/r26KmPvYLDaPjrdM0M7jL05MfjzbKs6YvpmQJsQIhF339EiJ+JwfGBlR4NnleXyYpkXclAZXOQKBgQC4GtSAdUjohsSHuq76PopZE6Nw2zOaWN3wwNp6OVM0MkTAl3ELDklpBcKTN00GeMOk7DxiwEJG1iFGJj9qZGi5hvhrjDbWdqFlPltJvRSQoabSLcO6AaoLB360T/OeZ5DS0dn7vZQw8ouO4C4Mtdlc7S/1ZodPsjwkh8aTsAXyjQKBgQC01t9zRBSyWu3R4ehU9EeAYGkafhZBWXyOY6XRyrYMlj/Y7avCojjwXWMvCX76UfZxpxaueLf6faiy5jxuBDhAYO3IqigdyzEkXVp70+ltkivPK2Y/HbZ0Sy0kDbxZ43vD2Teg721EaVDHx7wFQ/eKaqxKZThaL0+N4kDeg64bwQKBgC9MTU3XU+zROsp4Dp4h1R8/aV0EI8TCkfpZQYfnFFYzl/A2uAcUG44Mucliirpf6juDqZvhMuXJ+3BvQRmPRExtvYK72hbNEXfWRlOybQcfUKFsun0eElaVDVs7syX+C3nuCeef8+ODXJFPTOVdDsPN9+U++wJhkwv7ievFbDG9AoGBALJLnE1PdJf00RNxZAp8Vz4OIeTKRVRIeMC0o0it+pVT4jq2c13NuKSRQY/AMvD3wCfSwEdW56r6JM6fnBPM3kt7f+n2gA52liWqKyRaWqyjmTLUYmdu/QGKBjeegyhrKTTFdnpc1ez/aybthEYzbBrJtkPhvZWuM6U4waAL31Wl";
		//		data = "<?xml version=\"1.0\" encoding=\"utf-8\"?><requestObject><eventType>P501</eventType><airMissCost>0</airMissCost><apvruleId>25569</apvruleId><backOrderAndXePnr>false</backOrderAndXePnr><description>行程说明</description><emailToTC>0</emailToTC><hotelMissCost>0</hotelMissCost><isDividualJour>0</isDividualJour><isSendSms4BookedJourney>1</isSendSms4BookedJourney><journeyNo>100151728</journeyNo><needMailPassenger>1</needMailPassenger><orderType>0</orderType><selectedApvers>1085938</selectedApvers><sendSmsMobile4BookedJourney>18999999999</sendSmsMobile4BookedJourney><submitDirectly>0</submitDirectly><totalMissCost>0</totalMissCost><travelPurpose>旅行目的</travelPurpose><journeyVO><agentId>592</agentId><airItemPayStatus>n</airItemPayStatus><airItemVOList><airItemVO><agentId>592</agentId><airItemNo>1143152</airItemNo><airItemState>1</airItemState><airportTax>50</airportTax><b2bInputStatus>0</b2bInputStatus><b2bOutStatus>0</b2bOutStatus><b2bPayStatus>0</b2bPayStatus><bookedLowestType>0</bookedLowestType><bpnr>NZ7Q1T</bpnr><cancelFlag>0</cancelFlag><contrContent>违背全天最低价政策</contrContent><contrContentEn>违背全天最低价政策</contrContentEn><contrPolicy>1</contrPolicy><contrReason>123</contrReason><createtime>1479951278000</createtime><ei>余额再收30%退票费 余额再收20%退票费 当客票全部未使用，变更费按订座舱位公布运价20%收取。升舱差额和变更费同时发生时，累加差额和变更费用。 当客票全部未使用，变更费按订座舱位公布运价10%收取。升舱差额和变更费同时发生时，累加差额和变更费用。 </ei><eiEn>余额再收30%退票费 余额再收20%退票费 当客票全部未使用，变更费按订座舱位公布运价20%收取。升舱差额和变更费同时发生时，累加差额和变更费用。 当客票全部未使用，变更费按订座舱位公布运价10%收取。升舱差额和变更费同时发生时，累加差额和变更费用。 </eiEn><fuelTax>0</fuelTax><gpTktTag>0</gpTktTag><hasInsureFlag>0</hasInsureFlag><hasServiceFee>0</hasServiceFee><ifSupplement>0</ifSupplement><issueBy>1</issueBy><issueRuleId>5201</issueRuleId><jourType>OW</jourType><journeyCreatetime>1479951278000</journeyCreatetime><journeyNo>100151580</journeyNo><lostVolume>500</lostVolume><masterTktMachineNo>123</masterTktMachineNo><officeNo>BJS187</officeNo><parGuestname>玫瑰</parGuestname><passengerVOList><passengerVO><agentId>592</agentId><airItemNo>1143152</airItemNo><certNo>2222222222222</certNo><certType>2</certType><corpCode>lqCorpCmpn</corpCode><corpId>33396</corpId><costCenterInfo>LQ企业公司测试</costCenterInfo><email>liuqia1n123@travelsky.com</email><hostName>饭店</hostName><isTempPsg>0</isTempPsg><issueChannel>1</issueChannel><issueChannelBySeg>1</issueChannelBySeg><issueExPlatform>0</issueExPlatform><issueExPlatformBySeg>0</issueExPlatformBySeg><issueRemark>自有BSP出票</issueRemark><issueRemarkBySeg>自有BSP出票</issueRemarkBySeg><journeyCreatetime>1479951278000</journeyCreatetime><mobile>18911714050</mobile><passengerId>1172121</passengerId><psgName>玫瑰</psgName><psgNameEn>玫瑰</psgNameEn><psgParId>1085938</psgParId><sequenceNo>1</sequenceNo><ticketNumBySeg>8881172121</ticketNumBySeg><ticketNumber>8881172121</ticketNumber><ticketState>1</ticketState><ticketType>1</ticketType><ticketTypeBySeg>1</ticketTypeBySeg></passengerVO></passengerVOList><pnrCreatetime>1439256420000</pnrCreatetime><pnrNo>D610EC</pnrNo><priceType>PUB</priceType><priceTypeDesc>公布价</priceTypeDesc><recommend><agentId>592</agentId><airItemNo>1143153</airItemNo><airItemState>1</airItemState><airportTax>50</airportTax><b2bInputStatus>0</b2bInputStatus><b2bOutStatus>0</b2bOutStatus><b2bPayStatus>0</b2bPayStatus><bookedLowestType>0</bookedLowestType><cancelFlag>0</cancelFlag><contrPolicy>0</contrPolicy><createtime>1479951278000</createtime><ei>未使用的首个航班起飞前2到∞小时退票时,余额再收50%退票费 余额再收0退票费 未使用的首个航班起飞前2到∞小时变更时,，变更费按订座舱位公布运价30%收取。升舱差额和变更费同时发生时，累加差额和变更费用。 变更费按订座舱位公布运价50%收取。升舱差额和变更费同时发生时，累加差额和变更费用。 </ei><eiEn>未使用的首个航班起飞前2到∞小时退票时,余额再收50%退票费 余额再收0退票费 未使用的首个航班起飞前2到∞小时变更时,，变更费按订座舱位公布运价30%收取。升舱差额和变更费同时发生时，累加差额和变更费用。 变更费按订座舱位公布运价50%收取。升舱差额和变更费同时发生时，累加差额和变更费用。 </eiEn><falseOrder>1</falseOrder><fuelTax>0</fuelTax><gpTktTag>0</gpTktTag><hasInsureFlag>0</hasInsureFlag><hasServiceFee>0</hasServiceFee><ifSupplement>0</ifSupplement><jourType>OW</jourType><journeyCreatetime>1479951278000</journeyCreatetime><journeyNo>100151580</journeyNo><lowestType>1</lowestType><officeNo>BJS187</officeNo><parGuestname>玫瑰</parGuestname><pnrNo>D610EC</pnrNo><priceType>FBR_PUB</priceType><priceTypeDesc>公布价</priceTypeDesc><referenceId>b633aa42ae5448bb8b3c7defc23d21e5</referenceId><rmkCms>5</rmkCms><segmentVOList><segmentVO><agentId>592</agentId><airItemNo>1143153</airItemNo><airlineShortName></airlineShortName><airportTax>50</airportTax><arriveAirportName>SZX</arriveAirportName><arriveCity>SZX</arriveCity><arriveCityName>SZX</arriveCityName><arriveStn>SZX</arriveStn><arriveTerminal>T3</arriveTerminal><arriveTime>1480346400000</arriveTime><b2GRuleId>0</b2GRuleId><b2gRuleId>0</b2gRuleId><baseCabin>Y</baseCabin><baseFare>T</baseFare><cabinCode>T</cabinCode><cabinDiscount>3.5</cabinDiscount><cabinPriceOff>65%</cabinPriceOff><cabinType>Y</cabinType><craftTypeCode>325</craftTypeCode><craftTypeName></craftTypeName><falseOrder>1</falseOrder><flytime>02:50</flytime><fuelTax>0</fuelTax><journeyCreatetime>1479951278000</journeyCreatetime><marketAirline>MU</marketAirline><marketFltNo>5359</marketFltNo><mealName>未知</mealName><price>490</price><pubPrice>490</pubPrice><segmentId>1147203</segmentId><sequenceNo>1</sequenceNo><standardPrice>1400</standardPrice><stop>0</stop><stopover>0</stopover><takeoffAirprotName>SHA</takeoffAirprotName><takeoffCity>SHA</takeoffCity><takeoffCityName>SHA</takeoffCityName><takeoffStn>SHA</takeoffStn><takeoffTerminal>T2</takeoffTerminal><takeoffTime>1480336200000</takeoffTime><tpm>1343</tpm></segmentVO></segmentVOList><ticketPrice>490</ticketPrice><totalPrice>490</totalPrice><totalTax>50</totalTax></recommend><referenceId>b633aa42ae5448bb8b3c7defc23d21e5</referenceId><rmkCms>10</rmkCms><segmentVOList><segmentVO><agentId>592</agentId><airItemNo>1143152</airItemNo><airlineShortName></airlineShortName><airportTax>50</airportTax><arriveAirportName>SZX</arriveAirportName><arriveCity>SZX</arriveCity><arriveCityName>SZX</arriveCityName><arriveStn>SZX</arriveStn><arriveTerminal>T3</arriveTerminal><arriveTime>1480298400000</arriveTime><b2GRuleId>0</b2GRuleId><b2gRuleId>0</b2gRuleId><baseCabin>Y</baseCabin><baseFare>Q</baseFare><cabinCode>Q</cabinCode><cabinDiscount>7.1</cabinDiscount><cabinPriceOff>29%</cabinPriceOff><cabinType>Y</cabinType><craftTypeCode>330</craftTypeCode><craftTypeName></craftTypeName><flytime>02:50</flytime><fuelTax>0</fuelTax><journeyCreatetime>1479951278000</journeyCreatetime><marketAirline>CA</marketAirline><marketFltNo>1893</marketFltNo><mealName>未知</mealName><price>990</price><pubPrice>990</pubPrice><segmentId>1147202</segmentId><sequenceNo>1</sequenceNo><standardPrice>1400</standardPrice><stop>0</stop><stopover>0</stopover><takeoffAirprotName>PVG</takeoffAirprotName><takeoffCity>SHA</takeoffCity><takeoffCityName>SHA</takeoffCityName><takeoffStn>PVG</takeoffStn><takeoffTerminal>T2</takeoffTerminal><takeoffTime>1480288200000</takeoffTime><tpm>1343</tpm></segmentVO></segmentVOList><ticketPrice>990</ticketPrice><tktResult>1</tktResult><totalPrice>990</totalPrice><totalTax>50</totalTax></airItemVO></airItemVOList><airMissCost>500</airMissCost><allPsgNames>玫瑰</allPsgNames><appJourneyDesc>123</appJourneyDesc><apvHistoryVOList><apvHistoryVO><agentId>592</agentId><apvComm>223</apvComm><apvHisId>1039819</apvHisId><apverEmail>liuqian@travelsky.com</apverEmail><apverLevel>1</apverLevel><apverName>玫瑰 </apverName><apverParId>1085938</apverParId><createTime>1479951768000</createTime><journeyCreateTime>1479951278000</journeyCreateTime><journeyNo>100151580</journeyNo><toState>1</toState></apvHistoryVO></apvHistoryVOList><apvType>0</apvType><apvruleId>25569</apvruleId><backOrderAndXePnr>false</backOrderAndXePnr><bookUserType>1</bookUserType><bookerEmail>liuqian@travelsky.com</bookerEmail><bookerId>1014664</bookerId><bookerMobile>18911714050</bookerMobile><bookerName>玫瑰</bookerName><bookerTel>18911714050</bookerTel><contactEmail>liuqian@travelsky.com</contactEmail><contactName>玫瑰</contactName><contactParId>1085938</contactParId><contactTel>18911714050</contactTel><corpCode>lqCorpCmpn</corpCode><corpId>33396</corpId><costCenterInfo>LQ企业公司测试(玫瑰);</costCenterInfo><createtime>1479951278000</createtime><dataFrom>2</dataFrom><description>123</description><di>d</di><emailToTC>0</emailToTC><hotelMissCost>0</hotelMissCost><ifSyncOA>0</ifSyncOA><isDividualJour>0</isDividualJour><jourState>5</jourState><journeyNo>100151580</journeyNo><journeySource>0</journeySource><messagePushTo>1014662</messagePushTo><needApv>0</needApv><needMailPassenger>0</needMailPassenger><orderType>0</orderType><parId>1085938</parId><passengerVOList><passengerVO><agentId>592</agentId><airItemNo>1143152</airItemNo><certNo>2222222222222</certNo><certType>2</certType><corpCode>lqCorpCmpn</corpCode><corpId>33396</corpId><costCenterInfo>LQ企业公司测试</costCenterInfo><email>liuqian@travelsky.com</email><hostName>饭店</hostName><isTempPsg>0</isTempPsg><issueChannel>1</issueChannel><issueChannelBySeg>1</issueChannelBySeg><issueExPlatform>0</issueExPlatform><issueExPlatformBySeg>0</issueExPlatformBySeg><issueRemark>自有BSP出票</issueRemark><issueRemarkBySeg>自有BSP出票</issueRemarkBySeg><journeyCreatetime>1479951278000</journeyCreatetime><mobile>18911714050</mobile><passengerId>1172121</passengerId><psgName>玫瑰</psgName><psgNameEn>玫瑰</psgNameEn><psgParId>1085938</psgParId><sequenceNo>1</sequenceNo><ticketNumBySeg>8881172121</ticketNumBySeg><ticketNumber>8881172121</ticketNumber><ticketState>1</ticketState><ticketType>1</ticketType><ticketTypeBySeg>1</ticketTypeBySeg></passengerVO></passengerVOList><serviceCodeId>654550</serviceCodeId><serviceCodeName>lqServiceCode</serviceCodeName><stateUpTime>1479951783000</stateUpTime><submitDirectly>0</submitDirectly><tktIssueType>1</tktIssueType><totalMissCost>500</totalMissCost><travelPolicyId>25568</travelPolicyId><travelPurpose>888</travelPurpose></journeyVO></requestObject>";
		data="abc我爱你我的家";
		try {
			Map<String, Object> generateKeyPair = generateKeyPair();
			System.out.println("公钥："+getPublicKeyBytes(generateKeyPair));
			System.out.println("私钥："+getPrivateKeyBytes(generateKeyPair));
			byte[] encryptPublicKey = encryptPublicKey(data, publicKey);
			String byteToBase64 = b64encode(encryptPublicKey);
			System.out.println("加密后的密文："+byteToBase64);
			String sign = RSASignature.sign(data, privateKey);
			System.out.println("签名："+sign);
			String decryptPrivateKey = decryptPrivateKey(b64decode(byteToBase64),privateKey);
			System.out.println("解密后的密文："+decryptPrivateKey);
//				decryptPrivateKey="<?xml version='1.0' ?><requestObject><eventType>P501</eventType><airMissCost>0</airMissCost><apvruleId>25569</apvruleId><backOrderAndXePnr>false</backOrderAndXePnr><description>行程说明</description><emailToTC>0</emailToTC><hotelMissCost>0</hotelMissCost><isDividualJour>0</isDividualJour><isSendSms4BookedJourney>1</isSendSms4BookedJourney><journeyNo>100151728</journeyNo><needMailPassenger>1</needMailPassenger><orderType>0</orderType><selectedApvers>1085938</selectedApvers><sendSmsMobile4BookedJourney>18999999999</sendSmsMobile4BookedJourney><submitDirectly>0</submitDirectly><totalMissCost>0</totalMissCost><travelPurpose>旅行目的</travelPurpose><journeyVO><agentId>592</agentId><airItemPayStatus>n</airItemPayStatus><airItemVOList><airItemVO><agentId>592</agentId><airItemNo>1143152</airItemNo><airItemState>1</airItemState><airportTax>50</airportTax><b2bInputStatus>0</b2bInputStatus><b2bOutStatus>0</b2bOutStatus><b2bPayStatus>0</b2bPayStatus><bookedLowestType>0</bookedLowestType><bpnr>NZ7Q1T</bpnr><cancelFlag>0</cancelFlag><contrContent>违背全天最低价政策</contrContent><contrContentEn>违背全天最低价政策</contrContentEn><contrPolicy>1</contrPolicy><contrReason>123</contrReason><createtime>1479951278000</createtime><ei>余额再收30%退票费 余额再收20%退票费 当客票全部未使用，变更费按订座舱位公布运价20%收取。升舱差额和变更费同时发生时，累加差额和变更费用。 当客票全部未使用，变更费按订座舱位公布运价10%收取。升舱差额和变更费同时发生时，累加差额和变更费用。 </ei><eiEn>余额再收30%退票费 余额再收20%退票费 当客票全部未使用，变更费按订座舱位公布运价20%收取。升舱差额和变更费同时发生时，累加差额和变更费用。 当客票全部未使用，变更费按订座舱位公布运价10%收取。升舱差额和变更费同时发生时，累加差额和变更费用。 </eiEn><fuelTax>0</fuelTax><gpTktTag>0</gpTktTag><hasInsureFlag>0</hasInsureFlag><hasServiceFee>0</hasServiceFee><ifSupplement>0</ifSupplement><issueBy>1</issueBy><issueRuleId>5201</issueRuleId><jourType>OW</jourType><journeyCreatetime>1479951278000</journeyCreatetime><journeyNo>100151580</journeyNo><lostVolume>500</lostVolume><masterTktMachineNo>123</masterTktMachineNo><officeNo>BJS187</officeNo><parGuestname>玫瑰</parGuestname><passengerVOList><passengerVO><agentId>592</agentId><airItemNo>1143152</airItemNo><certNo>2222222222222</certNo><certType>2</certType><corpCode>lqCorpCmpn</corpCode><corpId>33396</corpId><costCenterInfo>LQ企业公司测试</costCenterInfo><email>liuqia1n123@travelsky.com</email><hostName>饭店</hostName><isTempPsg>0</isTempPsg><issueChannel>1</issueChannel><issueChannelBySeg>1</issueChannelBySeg><issueExPlatform>0</issueExPlatform><issueExPlatformBySeg>0</issueExPlatformBySeg><issueRemark>自有BSP出票</issueRemark><issueRemarkBySeg>自有BSP出票</issueRemarkBySeg><journeyCreatetime>1479951278000</journeyCreatetime><mobile>18911714050</mobile><passengerId>1172121</passengerId><psgName>玫瑰</psgName><psgNameEn>玫瑰</psgNameEn><psgParId>1085938</psgParId><sequenceNo>1</sequenceNo><ticketNumBySeg>8881172121</ticketNumBySeg><ticketNumber>8881172121</ticketNumber><ticketState>1</ticketState><ticketType>1</ticketType><ticketTypeBySeg>1</ticketTypeBySeg></passengerVO></passengerVOList><pnrCreatetime>1439256420000</pnrCreatetime><pnrNo>D610EC</pnrNo><priceType>PUB</priceType><priceTypeDesc>公布价</priceTypeDesc><recommend><agentId>592</agentId><airItemNo>1143153</airItemNo><airItemState>1</airItemState><airportTax>50</airportTax><b2bInputStatus>0</b2bInputStatus><b2bOutStatus>0</b2bOutStatus><b2bPayStatus>0</b2bPayStatus><bookedLowestType>0</bookedLowestType><cancelFlag>0</cancelFlag><contrPolicy>0</contrPolicy><createtime>1479951278000</createtime><ei>未使用的首个航班起飞前2到∞小时退票时,余额再收50%退票费 余额再收0退票费 未使用的首个航班起飞前2到∞小时变更时,，变更费按订座舱位公布运价30%收取。升舱差额和变更费同时发生时，累加差额和变更费用。 变更费按订座舱位公布运价50%收取。升舱差额和变更费同时发生时，累加差额和变更费用。 </ei><eiEn>未使用的首个航班起飞前2到∞小时退票时,余额再收50%退票费 余额再收0退票费 未使用的首个航班起飞前2到∞小时变更时,，变更费按订座舱位公布运价30%收取。升舱差额和变更费同时发生时，累加差额和变更费用。 变更费按订座舱位公布运价50%收取。升舱差额和变更费同时发生时，累加差额和变更费用。 </eiEn><falseOrder>1</falseOrder><fuelTax>0</fuelTax><gpTktTag>0</gpTktTag><hasInsureFlag>0</hasInsureFlag><hasServiceFee>0</hasServiceFee><ifSupplement>0</ifSupplement><jourType>OW</jourType><journeyCreatetime>1479951278000</journeyCreatetime><journeyNo>100151580</journeyNo><lowestType>1</lowestType><officeNo>BJS187</officeNo><parGuestname>玫瑰</parGuestname><pnrNo>D610EC</pnrNo><priceType>FBR_PUB</priceType><priceTypeDesc>公布价</priceTypeDesc><referenceId>b633aa42ae5448bb8b3c7defc23d21e5</referenceId><rmkCms>5</rmkCms><segmentVOList><segmentVO><agentId>592</agentId><airItemNo>1143153</airItemNo><airlineShortName></airlineShortName><airportTax>50</airportTax><arriveAirportName>SZX</arriveAirportName><arriveCity>SZX</arriveCity><arriveCityName>SZX</arriveCityName><arriveStn>SZX</arriveStn><arriveTerminal>T3</arriveTerminal><arriveTime>1480346400000</arriveTime><b2GRuleId>0</b2GRuleId><b2gRuleId>0</b2gRuleId><baseCabin>Y</baseCabin><baseFare>T</baseFare><cabinCode>T</cabinCode><cabinDiscount>3.5</cabinDiscount><cabinPriceOff>65%</cabinPriceOff><cabinType>Y</cabinType><craftTypeCode>325</craftTypeCode><craftTypeName></craftTypeName><falseOrder>1</falseOrder><flytime>02:50</flytime><fuelTax>0</fuelTax><journeyCreatetime>1479951278000</journeyCreatetime><marketAirline>MU</marketAirline><marketFltNo>5359</marketFltNo><mealName>未知</mealName><price>490</price><pubPrice>490</pubPrice><segmentId>1147203</segmentId><sequenceNo>1</sequenceNo><standardPrice>1400</standardPrice><stop>0</stop><stopover>0</stopover><takeoffAirprotName>SHA</takeoffAirprotName><takeoffCity>SHA</takeoffCity><takeoffCityName>SHA</takeoffCityName><takeoffStn>SHA</takeoffStn><takeoffTerminal>T2</takeoffTerminal><takeoffTime>1480336200000</takeoffTime><tpm>1343</tpm></segmentVO></segmentVOList><ticketPrice>490</ticketPrice><totalPrice>490</totalPrice><totalTax>50</totalTax></recommend><referenceId>b633aa42ae5448bb8b3c7defc23d21e5</referenceId><rmkCms>10</rmkCms><segmentVOList><segmentVO><agentId>592</agentId><airItemNo>1143152</airItemNo><airlineShortName></airlineShortName><airportTax>50</airportTax><arriveAirportName>SZX</arriveAirportName><arriveCity>SZX</arriveCity><arriveCityName>SZX</arriveCityName><arriveStn>SZX</arriveStn><arriveTerminal>T3</arriveTerminal><arriveTime>1480298400000</arriveTime><b2GRuleId>0</b2GRuleId><b2gRuleId>0</b2gRuleId><baseCabin>Y</baseCabin><baseFare>Q</baseFare><cabinCode>Q</cabinCode><cabinDiscount>7.1</cabinDiscount><cabinPriceOff>29%</cabinPriceOff><cabinType>Y</cabinType><craftTypeCode>330</craftTypeCode><craftTypeName></craftTypeName><flytime>02:50</flytime><fuelTax>0</fuelTax><journeyCreatetime>1479951278000</journeyCreatetime><marketAirline>CA</marketAirline><marketFltNo>1893</marketFltNo><mealName>未知</mealName><price>990</price><pubPrice>990</pubPrice><segmentId>1147202</segmentId><sequenceNo>1</sequenceNo><standardPrice>1400</standardPrice><stop>0</stop><stopover>0</stopover><takeoffAirprotName>PVG</takeoffAirprotName><takeoffCity>SHA</takeoffCity><takeoffCityName>SHA</takeoffCityName><takeoffStn>PVG</takeoffStn><takeoffTerminal>T2</takeoffTerminal><takeoffTime>1480288200000</takeoffTime><tpm>1343</tpm></segmentVO></segmentVOList><ticketPrice>990</ticketPrice><tktResult>1</tktResult><totalPrice>990</totalPrice><totalTax>50</totalTax></airItemVO></airItemVOList><airMissCost>500</airMissCost><allPsgNames>玫瑰</allPsgNames><appJourneyDesc>123</appJourneyDesc><apvHistoryVOList><apvHistoryVO><agentId>592</agentId><apvComm>223</apvComm><apvHisId>1039819</apvHisId><apverEmail>liuqian@travelsky.com</apverEmail><apverLevel>1</apverLevel><apverName>玫瑰 </apverName><apverParId>1085938</apverParId><createTime>1479951768000</createTime><journeyCreateTime>1479951278000</journeyCreateTime><journeyNo>100151580</journeyNo><toState>1</toState></apvHistoryVO></apvHistoryVOList><apvType>0</apvType><apvruleId>25569</apvruleId><backOrderAndXePnr>false</backOrderAndXePnr><bookUserType>1</bookUserType><bookerEmail>liuqian@travelsky.com</bookerEmail><bookerId>1014664</bookerId><bookerMobile>18911714050</bookerMobile><bookerName>玫瑰</bookerName><bookerTel>18911714050</bookerTel><contactEmail>liuqian@travelsky.com</contactEmail><contactName>玫瑰</contactName><contactParId>1085938</contactParId><contactTel>18911714050</contactTel><corpCode>lqCorpCmpn</corpCode><corpId>33396</corpId><costCenterInfo>LQ企业公司测试(玫瑰);</costCenterInfo><createtime>1479951278000</createtime><dataFrom>2</dataFrom><description>123</description><di>d</di><emailToTC>0</emailToTC><hotelMissCost>0</hotelMissCost><ifSyncOA>0</ifSyncOA><isDividualJour>0</isDividualJour><jourState>5</jourState><journeyNo>100151580</journeyNo><journeySource>0</journeySource><messagePushTo>1014662</messagePushTo><needApv>0</needApv><needMailPassenger>0</needMailPassenger><orderType>0</orderType><parId>1085938</parId><passengerVOList><passengerVO><agentId>592</agentId><airItemNo>1143152</airItemNo><certNo>2222222222222</certNo><certType>2</certType><corpCode>lqCorpCmpn</corpCode><corpId>33396</corpId><costCenterInfo>LQ企业公司测试</costCenterInfo><email>liuqian@travelsky.com</email><hostName>饭店</hostName><isTempPsg>0</isTempPsg><issueChannel>1</issueChannel><issueChannelBySeg>1</issueChannelBySeg><issueExPlatform>0</issueExPlatform><issueExPlatformBySeg>0</issueExPlatformBySeg><issueRemark>自有BSP出票</issueRemark><issueRemarkBySeg>自有BSP出票</issueRemarkBySeg><journeyCreatetime>1479951278000</journeyCreatetime><mobile>18911714050</mobile><passengerId>1172121</passengerId><psgName>玫瑰</psgName><psgNameEn>玫瑰</psgNameEn><psgParId>1085938</psgParId><sequenceNo>1</sequenceNo><ticketNumBySeg>8881172121</ticketNumBySeg><ticketNumber>8881172121</ticketNumber><ticketState>1</ticketState><ticketType>1</ticketType><ticketTypeBySeg>1</ticketTypeBySeg></passengerVO></passengerVOList><serviceCodeId>654550</serviceCodeId><serviceCodeName>lqServiceCode</serviceCodeName><stateUpTime>1479951783000</stateUpTime><submitDirectly>0</submitDirectly><tktIssueType>1</tktIssueType><totalMissCost>500</totalMissCost><travelPolicyId>25568</travelPolicyId><travelPurpose>888</travelPurpose></journeyVO></requestObject>";
			/*Map<String, String> encryptSignData = encryptSignData(data, privateKey, pub);
			String encryptData = encryptSignData.get("encryptData");
			System.out.println("加密后："+encryptData);
			String encrytSign = encryptSignData.get("encrytSign");
			Map<Object, Object> decryptSignData = decryptSignData(encryptData, encrytSign, pri, publicKey);
			Boolean isAccess = (Boolean) decryptSignData.get("isAccess");
			String decryptData = (String) decryptSignData.get("decryptData");
			System.out.println("解密后："+decryptData);
			System.out.println("验证签名："+isAccess);*/

		} catch (Exception e) {
			e.printStackTrace();
		}
	}
    private static String b64encode(byte[] data) {

		String b64str = new String(Base64.encode(data));
		return b64str;
	}

	private static byte[] b64decode(String data) {
		byte[] decodeData = Base64.decode(data);
		return decodeData;
	}

}
